package edu.mis.modules.category;

import com.jfinal.core.Controller;

import edu.mis.model.Category;


public class CategoryController extends Controller {
	
	static CategoryService service = new CategoryService();
	
	public void index() {
		render("category.html");
	}
	
	public void list(){
		setAttr("data", service.findAllCategory());
		renderJson();  
	}

	public void add() {
		    //render("add.html");  
	}

	public void register(){
		Category category  =  getModel(Category.class);  
		if(service.register(category)){
			
			setAttr("result", true); 
			setAttr("msg", "添加商品类别成功!"); 
		}else{
			setAttr("result",false);
			setAttr("msg", "添加失败，商品类别重复!"); 
		}
		renderJson(); 
	}
}


